package com.ruoyi.web.controller.warn;

import com.ruoyi.base.domain.BusWarnWarninfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.warn.domain.PsCodPollutant;
import com.ruoyi.warn.domain.WarnInfoVo;
import com.ruoyi.warn.service.WarnDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/warn")
public class WarnDataController extends BaseController {
    @Autowired
    private WarnDataService warnDataService;

    /**
     * 查询断面预警信息
     */
    @GetMapping("/segmentWarnData")
    public TableDataInfo getSegmentWarnData(WarnInfoVo vo) {
        List<BusWarnWarninfo> data = warnDataService.getSegmentWarnData(vo);
        return getDataTable(data);
    }

    /**
     * 在线监测报警列表查询
     */
    @GetMapping("/warnPsMonitoringList")
    public TableDataInfo warnPsMonitoringList(WarnInfoVo vo) {
        startPage();
        List<BusWarnWarninfo> data = warnDataService.warnPsMonitoringList(vo);
        return getDataTable(data);
    }

    /**
     * 视频预警列表查询
     */
    @GetMapping("/warnVideoList")
    public TableDataInfo warnVideoList(WarnInfoVo vo) {
        startPage();
        List<BusWarnWarninfo> data = warnDataService.warnVideoList(vo);
        return getDataTable(data);
    }

    /**
     * 污染因子
     */
    @GetMapping("/pollutantList")
    public AjaxResult pollutantList(PsCodPollutant psCodPollutant)
    {
        psCodPollutant.setPollutantTypeCode(1L);
        List<PsCodPollutant> list = warnDataService.selectPsCodPollutantList(psCodPollutant);
        return AjaxResult.success(list);
    }

    /**
     * 预警类型综合
     */
    @GetMapping("/warnTypeList")
    public AjaxResult warnTypeList(WarnInfoVo vo) {
        List<SysDictData> retList=new ArrayList<>();
        //从缓存中获取预警类型
        List<SysDictData> warnTypeDataList= DictUtils.getDictCache("warn_type_data");
        List<SysDictData> videoTypeList= DictUtils.getDictCache("warn_video_type");
        List<SysDictData> psmonitoringTypeList= DictUtils.getDictCache("warn_psmonitoring_type");
        retList.addAll(warnTypeDataList);
        retList.addAll(videoTypeList);
        retList.addAll(psmonitoringTypeList);

        return AjaxResult.success(retList);
    }


}
